package com.erpanderp.wam.ac.view.reimbursement;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.erpanderp.wam.ac.model.entity.reimbursement.MiscExpense;
import com.erpanderp.wam.ac.model.service.reimbursement.MiscReimbursementDAO;
import com.erpanderp.wam.util.CommonLookup;
import com.erpanderp.wam.util.WAMUtil;

@ManagedBean
@ViewScoped
public class MiscExpenseReportBean implements Serializable{

	private static final long serialVersionUID = 1L;
	private TimeZone timeZone = TimeZone.getDefault();
	
	private Map<String, Integer> monthsMap = CommonLookup.getMonths();
	private Map<String, Integer> yearsMap = WAMUtil.getLastSixYears();
	private Map<String, String>  statusMap = CommonLookup.getAllStatus();
	private List<MiscExpense> miscExpensesList=new ArrayList<MiscExpense>();
	
	private MiscReimbursementDAO miscReimbursementDAO=new MiscReimbursementDAO();
	
	private Integer selectedMonth;
	private Integer selectedYear;
	private String selectedStatus;	
	private boolean renderMiscExpenseList;
	private int sNo=1;

	public MiscExpenseReportBean() {
		
		//miscExpensesList = miscReimbursementDAO.getAllMiscExpenses(getSelectedYear(),getSelectedMonth(),getSelectedStatus());
	}

	//SEARCH ACTION
	public String miscexpenseReportAction(){
			System.out.println("Search Action...");
				
			miscExpensesList = miscReimbursementDAO.getAllMiscExpenses(selectedYear,selectedMonth+1,selectedStatus);
			
			for(MiscExpense mexp:miscExpensesList){
				mexp.setsNo(sNo);
				sNo++;
			}
			
			if(miscExpensesList != null && miscExpensesList.size() > 0){
				renderMiscExpenseList=true;
			}else{
				renderMiscExpenseList=false;
			}		
			return null;
	}

	//SETTERS AND GETTERS
	public Map<String, Integer> getMonthsMap() {
		return monthsMap;
	}

	public void setMonthsMap(Map<String, Integer> monthsMap) {
		this.monthsMap = monthsMap;
	}

	public Map<String, Integer> getYearsMap() {
		return yearsMap;
	}

	public void setYearsMap(Map<String, Integer> yearsMap) {
		this.yearsMap = yearsMap;
	}

	public Map<String, String> getStatusMap() {
		return statusMap;
	}

	public void setStatusMap(Map<String, String> statusMap) {
		this.statusMap = statusMap;
	}

	public Integer getSelectedMonth() {
		return selectedMonth;
	}

	public void setSelectedMonth(Integer selectedMonth) {
		this.selectedMonth = selectedMonth;
	}

	public Integer getSelectedYear() {
		return selectedYear;
	}

	public void setSelectedYear(Integer selectedYear) {
		this.selectedYear = selectedYear;
	}

	public String getSelectedStatus() {
		return selectedStatus;
	}

	public void setSelectedStatus(String selectedStatus) {
		this.selectedStatus = selectedStatus;
	}

	public boolean isRenderMiscExpenseList() {
		return renderMiscExpenseList;
	}

	public void setRenderMiscExpenseList(boolean renderMiscExpenseList) {
		this.renderMiscExpenseList = renderMiscExpenseList;
	}

	public List<MiscExpense> getMiscExpensesList() {
		return miscExpensesList;
	}

	public void setMiscExpensesList(List<MiscExpense> miscExpensesList) {
		this.miscExpensesList = miscExpensesList;
	}

	public MiscReimbursementDAO getMiscReimbursementDAO() {
		return miscReimbursementDAO;
	}

	public void setMiscReimbursementDAO(MiscReimbursementDAO miscReimbursementDAO) {
		this.miscReimbursementDAO = miscReimbursementDAO;
	}

	public int getsNo() {
		return sNo;
	}

	public void setsNo(int sNo) {
		this.sNo = sNo;
	}

	public TimeZone getTimeZone() {
		return timeZone;
	}

	public void setTimeZone(TimeZone timeZone) {
		this.timeZone = timeZone;
	}

}
